import { type WebSocket } from 'ws';

export interface CustomSocket extends WebSocket {
  user_id: string;
}

export interface GameMsg {
  id: number;
  data: Record<string, any>;
}

export interface UserInfo {
  name: string;
  level: number;
  exp: number;
  gold: number;
  silver: number;
  vip: number;
  sponsor: number;
  power: number;
  honor: number;
}

export interface UserArraying {
  id: string;
  heroId: string;
  position: [number, number];
}

export interface UserRole {
  id: string;
  heroId: string;
  heroName: string;
  heroAvatar: string;
  level: number;
  exp: number;
  position: [number, number];
  equip: string[];
  talent: number[];
  hp: number;
  attack: number;
  defence: number;
  speed: number;
  skill1: number;
  skill2: number;
  skill3: number;
}

export interface UserEquip {
  id: string;
  equipId: string;
  heroId: string;
  level: number;
  exp: number;
  type: number;
  hp: number;
  attack: number;
  defence: number;
  speed: number;
}

export interface UserGoods {
  id: string;
  goodsId: string;
  count: number;
}

export interface BattleAttr {
  /**
   * 生命值
   **/
  HP: number;
  /**
   * 攻击力
   **/
  ATK: number;
  /**
   * 防御力
   **/
  DEF: number;
  /**
   * 速度
   **/
  SPD: number;
  /**
   * 命中
   **/
  HIT: number;
  /**
   * 闪避
   **/
  PRY: number;
  /**
   * 暴击
   **/
  CRIT: number;
  /**
   * 忽略暴击
   **/
  CRIRES: number;
  /**
   * 伤害加深
   **/
  DMGADD: number;
  /**
   * 伤害减免
   **/
  DMGRED: number;
  /**
   * 怒气
   **/
  ANGRY: number;
  /**
   * 控制
   **/
  CTRL: number;
  /**
   * 眩晕
   **/
  STUN: number;
  /**
   * 免疫眩晕
   **/
  STUNRES: number;
}

export interface Buff {
  /**
   * buff 类型 1:攻击 2血量 ...
   * */
  BUFF: number;
  /**
   * 效果 3: 减益 4: 增益
   */
  EFF: number;
  /**
   * 加成类型 0 固定数值 1 千分比
   **/
  TYPE: number;
  /**
   * 加成数值
   **/
  VAL: number;
  /**
   * 技能持续回合
   **/
  RND: number;
}

export interface BattleCard {
  /**
   * 卡牌来源
   **/
  from: string;
  base: UserRole;
  battle: BattleAttr;
  buff: Buff[];
}

export interface Skill {
  id: number;
  name: string;
  description: string;
  type: number;
  action: number;
  area: number;
  limits: number;
  ratio: number;
  round: number;
  additional: number;
  logic1: number;
  logic1_type: number;
  logic1_parameter: number;
  logic1_round: number;
  logic2: number;
  logic2_type: number;
  logic2_parameter: number;
  logic2_round: number;
  logic3: number;
  logic3_type: number;
  logic3_parameter: number;
  logic3_round: number;
}

export interface SkillInfo {
  skill: Skill;
  type: number;
}

export interface CardAction {
  id: string;
  from: string;
  to: string;
  avatar: string;
  skill: number;
  skillType: number;
  target: TargetAction[];
  angry: number;
}

export interface TargetAction {
  id: string;
  from: string;
  action: number;
  buff: Buff[];
  hit: number;
  crit: number;
  dmg: number;
  die: number;
  recover: number;
  hp: number;
  angry: number;
}

export interface RoundEndAction {
  id: string;
  angry: number;
  // postion: [number, number];
}

export interface BattleData {
  round: number;
  action: CardAction[];
  end: RoundEndAction[];
}

export interface BattleReward {
  id: number;
  count: number;
}

export interface BattleResult {
  type: number;
  totalDmg: number;
  ownName: string;
  foeName: string;
  own: BattleCard[];
  foe: BattleCard[];
  battle: BattleData[];
  reward: BattleReward[];
}
